package org.dromara.common.translation.core.impl;

import lombok.AllArgsConstructor;
import org.dromara.common.core.service.ScheduleService;
import org.dromara.common.translation.annotation.TranslationType;
import org.dromara.common.translation.constant.TransConstant;
import org.dromara.common.translation.core.TranslationInterface;


/**
 * 用户名翻译实现
 *
 * @author Lion Li
 */
@AllArgsConstructor
@TranslationType(type = TransConstant.SCHEDULE_ID_TO_NAME)
public class ScheduleNameTranslationImpl implements TranslationInterface<String> {

    private final ScheduleService scheduleService;

    @Override
    public String translation(Object key, String other) {
        if (key instanceof String ids) {
            return scheduleService.selectScheduleNameById(Long.parseLong(ids));
        } else if (key instanceof Long id) {
            return scheduleService.selectScheduleNameById(id);
        }
        return null;
    }
}
